
import {Injectable} from '@angular/core';


@Injectable()
export class SessionStorage{
	public sessionStorage:any;
	constructor(){
		window.sessionStorage ? this.sessionStorage = window.sessionStorage : console.log("您的浏览器不支持本地存储");
	}
	public set(key:string,value:string):void{
		this.sessionStorage.setItem(key,value);
	}
	public get(key:string):string{
		return this.sessionStorage.getItem(key);
	}
	public setJson(key:string,value:object):void{
		this.sessionStorage.setItem(key,JSON.stringify(value));
	}
	public getJson(key:string):object{
		return JSON.parse(this.sessionStorage.getItem(key));
	}
	public remove(key:string):void{
		this.sessionStorage.removeItem(key);
	}
	public clear():void {
		this.sessionStorage.clear();
	}
}
